<?php

namespace drivers;

class autoload{

    protected static $drivers = array(
        /*"autoload"=> 'drivers/autoload',
        "config"=>'drivers/config',
        "start"=>'drivers/start',
        "factory"=>'drivers/factory',
        "routes"=>'drivers/routes',
        "TException"=>'drivers/TException',*/
    );

    protected static $ext = '.php';

    static function inc($class){

        if (isset(self::$drivers[$class])){
            include_once (__ROOT__.self::$drivers[$class].self::$ext);
        }else{

            $file = __ROOT__.str_replace("\\",'/',$class).self::$ext;
            if (file_exists($file)){
                include_once ($file);
            }else{
                throw new TException("没有找到 $class 类");
            }
        };
    }
}